{{ define "content" }}
<article class="post-warp" itemscope itemtype="http://schema.org/Article">
    <header class="post-header">
        <h1 class="post-title" itemprop="name headline">{{ .Title }}</h1>
        <div class="post-meta">
                Written by <a itemprop="name" href="{{.Site.BaseURL }}" rel="author">{{ if isset .Params "author" }}{{ .Params.author }}{{ else }}{{ .Site.Params.author }}{{ end }}</a> with ♥
                <span class="post-time">
                on <time datetime={{.Date.Format (.Site.Params.dateFormatToUse | default "2006-01-02") }} itemprop="datePublished">{{ .Date.Format (.Site.Params.dateFormatToUse | default "January 2, 2006") }}</time>
                </span>
                in
                {{ with .Params.categories }}
                <i class="iconfont icon-folder"></i>
                <span class="post-category">
                        {{ range . }}
                        {{ $name := . }}
                        {{ with $.Site.GetPage "taxonomy" (printf "categories/%s" $name) | default ($.Site.GetPage "taxonomy" (printf "categories/%s" ($name | urlize))) }}
                          <a href="{{ .Permalink }}"> {{ $name }}, </a>
                        {{ end }}
                        {{ end }}
                </span>
                {{- end }}
                <span class="post-word-count">{{ .WordCount }} words</span>
        </div>
    </header>

    <div class="post-content">
        <!--featured_image-->

        {{ $images := findRE "<img src=\"[^\"|\\\"]*\"" .Content }}
        {{ if ge (len $images) 1}}
            {{ $.Scratch.Set "postHasImages" true }}
        {{ end }}

        {{ with .Params.featured_image }}
          {{ $img := . -}}
          <img src="{{ printf "%s" $img }}" class="featured_image" loading="lazy">
        {{ end }}
        <!-- end featured_image-->
        {{ $reImgIn := "<img src=\"([^\"]+)\" alt=\"([^\"]+)\">" }}
        {{ $reImgOut := "<img src=\"$1\" alt=\"$2\" loading=\"lazy\" >" }}
        {{ $tmpContent := .Content | replaceRE $reImgIn $reImgOut | safeHTML }}

        {{ $reImgTitleIn := "<img src=\"([^\"]+)\" alt=\"([^\"]+)?\" title=\"([^\"]+)?\">" }}
        {{ $reImgTitleOut := "<figure><img src=\"$1\" alt=\"$2\" title=\"$3\" loading=\"lazy\" ><figcaption>$3</figcaption></figure>" }}
        {{ $finalContent := $tmpContent | replaceRE $reImgTitleIn $reImgTitleOut | safeHTML }}

        {{ $finalContent }}
    </div>

    <div class="post-copyright">
            {{ with .Site.Params.author }}
            <p class="copyright-item">
                <span>Author:</span>
                <span>{{ . }} </span>
                </p>
            {{ end }}

            {{ with .Permalink }}
            <p class="copyright-item">
                    <span>Link:</span>
                    <a href={{ . }}>{{ . }}</span>
            </p>
            {{ end }}
            {{ with .Site.Params.license }}
            <p class="copyright-item lincese">
                {{ . | safeHTML}}
            </p>
            {{ end }}
    </div>


    <div class="post-tags">
        {{ with .Params.tags }}
            <section>
            <i class="iconfont icon-tag"></i>Tag(s):
            {{ range . }}
            <span class="tag"><a href="{{ "tags/" | absURL }}{{ . | urlize }}/">
                    #{{.}}</a></span>
            {{ end }}
            </section>
        {{ end }}
        <section>
                <a href="javascript:window.history.back();">back</a></span> ·
                <span><a href="{{ .Site.BaseURL }}">home</a></span>
        </section>
    </div>

    <div class="post-nav">
        {{ if .PrevInSection }}
        <a href="{{.PrevInSection.Permalink}}" class="prev" rel="prev" title="{{ .PrevInSection.Title}}"><i class="iconfont icon-left"></i>&nbsp;{{ .PrevInSection.Title}}</a>
        {{ end }}
        {{ if .NextInSection }}
        <a href="{{.NextInSection.Permalink}}" class="next" rel="next" title="{{.NextInSection.Title}}">{{.NextInSection.Title}}&nbsp;<i class="iconfont icon-right"></i></a>
        {{ end }}
    </div>

    <div class="post-comment">
        <script src="https://utteranc.es/client.js"
            repo="SuperSupeng/superssssss.cn"
            issue-term="pathname"
            theme="github-light"
            crossorigin="anonymous"
            async>
        </script>
    </div>
</article>
{{- end }}
